package com.ylfstu.try_;

/**
 * @author:Joy_Yang
 * @date:2022/9/27
 * @version:1.0
 */
public class customexception {
    public static void main(String[] args) {
        int age = 80;
        if (!(age >= 18 && age <= 120)) {
            throw new AgeException("抱歉，年龄需要在18~120之间");
        }
        System.out.println("您的年龄范围正确...");
    }
}
//自定义一个异常
class AgeException extends RuntimeException{
    public AgeException(String message) {
        super(message);
    }
}
